package com.chmingx.boot.bean;

import com.chmingx.boot.dao.DBHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Component;

@ImportResource("classpath:beans.xml") // 导入beans.xml, 将xml中的组件注册到容器中
@Import({DBHelper.class})  // 给容器中自动创建出这个数组中指定类型的组件，组件默认名字就是全类名
//@Conditional() 条件装配，满足条件才进行组件注入
//@ConditionalOnMissingBean(name="person")  // 没有变量名为person的变量时候才进行装配
@Component
public class Person {
    @Value("foobar")
    private String name;

    @Value("20")
    private int age;

}
